package com.config;

import io.netty.channel.nio.NioEventLoopGroup;
import lombok.extern.slf4j.Slf4j;

import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * @author linyu.dai
 * @project rpc
 * @description
 * @creat 2022/11/27 11:29:56
 */
@Slf4j
public class Config {

    private static Properties properties;

    static {
        //加载配置文件
        try(InputStream resourceAsStream = Config.class.getClassLoader().getResourceAsStream("application.properties")){
            properties = new Properties();
            properties.load(resourceAsStream);
        }catch (IOException exception){
            log.error("file loading error {}",exception.getMessage());
        }
    }

    /**
     * 获取配置信息
     */
    public static String get(String key){
        return (String) properties.get(key);
    }

    public static ExecutorService getExecutorService(){
        return new NioEventLoopGroup(5);
    }
}
